package com.io.example.demoparent.controller;

import com.io.example.demoparent.annotation.Limit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @program: demo-project
 * @ClassName LimitController
 * @description:
 * @author: 宠儿
 * @create: 2024−09-01 15:50
 * @Version 1.0
 **/
@RestController
@Slf4j
@RequestMapping("limit")
public class LimitController {

    @GetMapping("/test")
    @Limit(key = "limit", permitsPerSecond = 1, timeout = 50, timeunit = TimeUnit.MILLISECONDS, msg = "系统繁忙，请稍后再试！")
    public String limit3() {
        log.info("令牌桶limit获取令牌成功");
        return "ok";
    }
}
